home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Peter's Final Project / src / texture.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  2.6 KB  |  72 lines  |  [TEXT/KAHL]

  1. /*
  2.  *  Peter's Final Project -- A texture mapping demonstration
  3.  *  © 1995, Peter Mattis
  4.  *
  5.  *  E-mail:
  6.  *  petm@soda.csua.berkeley.edu
  7.  *
  8.  *  Snail-mail:
  9.  *   Peter Mattis
  10.  *   557 Fort Laramie Dr.
  11.  *   Sunnyvale, CA 94087
  12.  *
  13.  *  Avaible from:
  14.  *  http://www.csua.berkeley.edu/~petm/final.html
  15.  *
  16.  *  This program is free software; you can redistribute it and/or modify
  17.  *  it under the terms of the GNU General Public License as published by
  18.  *  the Free Software Foundation; either version 2 of the License, or
  19.  *  (at your option) any later version.
  20.  *
  21.  *  This program is distributed in the hope that it will be useful,
  22.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  23.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24.  *  GNU General Public License for more details.
  25.  *
  26.  *  You should have received a copy of the GNU General Public License
  27.  *  along with this program; if not, write to the Free Software
  28.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29.  */
  30.  
  31. #ifndef __TEXTURE_H__
  32. #define __TEXTURE_H__
  33.  
  34. #include "type.defs.h"
  35.  
  36. TEXTURE make_texture (void);
  37. void free_texture (TEXTURE);
  38.  
  39. void texture_checker (TEXTURE, short);
  40. void texture_read (TEXTURE, char *);
  41.  
  42. #define texture_address(t)            ((t)->addr)
  43. #define texture_size(t)               ((t)->size)
  44. #define texture_size_log2(t)          ((t)->size_log2)
  45. #define texture_bytes_per_texel(t)    ((t)->bytes_per_texel)
  46. #define texture_element8(t, i, j)     (*((char*) texture_address(t) + \
  47. ((j) << texture_size_log2(t)) + (i)))
  48. #define texture_element16(t, i, j)    (*((short*) texture_address(t) + \
  49. ((j) << texture_size_log2(t)) + (i)))
  50. #define texture_element32(t, i, j)    (*((long*) texture_address(t) + \
  51. ((j) << texture_size_log2(t)) + (i)))
  52.  
  53. #define set_texture_address(t, k)           (texture_address(t) = (k))
  54. #define set_texture_size(t, k)               (texture_size(t) = (k))
  55. #define set_texture_size_log2(t, k)          (texture_size_log2(t) = (k))
  56. #define set_texture_bytes_per_texel(t, k)    (texture_bytes_per_texel(t) = (k))
  57. #define set_texture_element8(t, i, j, k)     (texture_element8(t, i, j) = (k))
  58. #define set_texture_element16(t, i, j, k)    (texture_element16(t, i, j) = (k))
  59. #define set_texture_element32(t, i, j, k)    (texture_element32(t, i, j) = (k))
  60.  
  61. #define texel8      texture_element8
  62. #define texel16     texture_element16
  63. #define texel24     texture_element32
  64. #define texel32     texture_element32
  65.  
  66. #define set_texel8   set_texture_element8
  67. #define set_texel16  set_texture_element16
  68. #define set_texel32  set_texture_element32
  69. #define set_texel32  set_texture_element32
  70.  
  71. #endif /* __TEXTURE_H__ */
  72.